//
//  ViewController.swift
//  YSM
//
//  Created by ys on 2018/7/13.
//  Copyright © 2018年 ys. All rights reserved.
//

import UIKit

class BaseViewController: UIViewController, YSRouterCommonProtocol {
    var removeTag: String = ""
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.initData()
        self.initView()
        self.registerNotify()
    }
    
    deinit {
        print("\(self)已经销毁")
        NotificationCenter.default.removeObserver(self)
        YSRouterCommon.romveRouterCommon(target: self)
    }
    
    private func initData() {
        self.view.backgroundColor = UIColor.white
    }
    private func initView() {
        
        if self.navigationController?.viewControllers.index(of: self) != 0 {
            self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "back", style: .plain, target: self, action: #selector(leftbackItemAction))
        }
    }
    private func registerNotify() {
        
    }

    @objc private func leftbackItemAction() {
        self.navigationController?.popViewController(animated: true)
    }
    
    /// 写一个基类方法，所有页面传值都可以调用
    func loadVCInfo(params:Any) {
    }
    
    ///
    func reciveRouterCommon(name: Notification.Name, params: Any?) {
    }

}
